import "./register.css";
import useForm from "@module/useForm";
import Input from "@ui/RJMart/input";
import Icon from "@ui/RJMart/icons";
import RSA from "@module/EncryptPW";
import message from "@ui/RJMart/message";

export default function StepTwo(props) {
    const params = $state.params;
    const { registerType, email, password, confirmPassword, token } =
        params || {};

    function sendAgain() {
        ZenUI.SL(60);
        let sendUrl, sendData;
        if (params.registerType == 1) {
            sendUrl = "/store/api/invite/sendRegisterEmail";
            sendData = {
                email: params.email,
                confirmPassword: params.confirmPassword,
                password: params.password,
                token: params.token
            };
        } else {
            sendUrl = "/suppliers/anon/supplierRegister";
            sendData = {
                email: params.email,
                password: params.password
            };
        }
        REST.post(sendUrl, sendData, "noInfo").then(
            function(data) {
                ZenUI.HL();
                console.log(data);
                if (data.code == "0000") {
                    // alert("邮件已重发成功，请查收！");
                    message.info("邮件已重发成功，请查收！");
                }
            },
            function(error) {
                ZenUI.HL();
                console.log(error);
            }
        );
    }

    return (
        <div className={"regi-step-two"}>
            <div className={"regi-step2-top"}>
                <div
                    className={
                        "zen_il-bl zen_w-56 zen_h-56 zen_m-h-30 zen_m-v-10 regi-step2-top-img"
                    }
                />
                <div className={"regi-step2-top-txt"}>
                    <p>激活平台账号</p>
                    <p
                        className={"regi-step2-email"}
                    >{`邮件已发送至你的注册邮箱：${
                        params.email
                    }。请进入邮箱查看并激活账号。`}</p>
                </div>
            </div>
            <div className={"regi-step2-bottom"}>
                <p className={"zen_fs-18 zen_3C3C3C"}>没有收到邮件？</p>
                <p className={"zen_969696 zen_fs-12 zen_l-h-16 zen_m-t-20"}>
                    1. 请检查邮箱地址是否正确，你可以返回
                    <span
                        onClick={() => {
                            $state.go({
                                stateName: "/register",
                                params: {
                                    step: 1,
                                    registerType: params.registerType,
                                    token: params.token
                                }
                            });
                        }}
                        className={"zen_0094EB zen_cur-p"}
                    >
                        重新填写
                    </span>
                </p>
                <p className={"zen_969696 zen_fs-12 zen_l-h-16 zen_m-t-10"}>
                    2. 检查你的邮件垃圾箱
                </p>
                <p className={"zen_969696 zen_fs-12 zen_l-h-16 zen_m-t-10"}>
                    3. 若仍未收到确认，请尝试
                    <span
                        onClick={sendAgain}
                        className={"zen_0094EB zen_cur-p"}
                    >
                        重新发送
                    </span>
                </p>
            </div>
        </div>
    );
}
